<template>
    <view class="add">
		<block v-if="!boxHide">
			<view class="add_item">
				<view>退还仓库</view>
				<picker mode="selector" :range="houseList" @change="getPickerValue" :range-key="'title'" class="add_picker" :data-index="5" :data-indexs="index">
					<text>{{house.wareName}}</text>
					<image src="/static/images/right.png" class="right"></image>
				</picker>
			</view>
			
			<view class="add_item">
				<view>数量</view>
				<input type="text" v-model="refund.number" placeholder="请输入数量"/>
			</view>
			
			<view class="add_textarea" v-if="!inputhide">
				<view>备注</view>
				<textarea v-model="refund.desc"   placeholder="请输入备注" />
			</view>
			<view class="save" @tap="handBack()">保存</view>
		</block>
		<Loading ref="load"></Loading>
	</view>
</template>
<script>
    export default {
	    data(){
			return{
				load:{},
                boxHide:false,
				backType:1, // 退还类型：配件\损件
 				houseList:[], // 仓库数据
				refund:{desc:''}, // 退还封装
				house:{     
					warehouseId:0,
					wareName:''
				},
 			}
		},
		onLoad(options) { 
			
			this.backType = options.type;
			if(this.backType == 1){
				this.setNavTitle('配件退还');
			}else{
				this.setNavTitle('损件退还');
			}
			this.house.warehouseId = options.warehouseId;
			this.house.wareName = options.wareName;

			this.refund = {id:options.id,product_id:options.productId,type:options.type,out_warehouse_id:options.warehouseId,number:options.num,desc:''};

			this.getWarehouse();
 		},
		onShow() {
			 
		},
		methods:{  
			// 设置标题 
			setNavTitle(title) {
				uni.setNavigationBarTitle({
					title
				})
			},
			// 获取库房数据
			getWarehouse(){

				this.$api.getProductLibrary({}).then(res => {
					this.houseList = res; 
				})
				
			},
            // 退还
            handBack(){

				console.log("--->>>>>",this.refund);

				this.$api.partsRefund(this.refund)
 
			},
			getPickerValue(e){
 				
				let ware = this.houseList[e.detail.value];
			
				this.refund.out_warehouse_id = ware.id;
				this.house.warehouseId = ware.id;
				this.house.wareName = ware.title;
			}
		}
    
    }
</script>
<style>
	.add{width: 100%;background: #FFFFFF;padding-bottom: 50upx;}

</style>
